package com.huang.factory;

/**
 * <p>操作类</p>
 *
 * @author aneng huang
 * @since 2020-10-27 10:35:56
 */
public class OperatorOne {


    public static double getResult(String operator, double numberOne, double numberTwo) {
        double result;
        switch (operator) {
            case "+":
                result = numberOne + numberTwo;
                break;
            case "-":
                result = numberOne - numberTwo;
                break;
            case "*":
                result = numberOne * numberTwo;
                break;
            case "/":
                if (numberTwo == 0) {
                    throw new RuntimeException("除数不能为0");
                }
                result = numberOne / numberTwo;
                break;
            default:
                throw new RuntimeException("操作不存在");
        }
        return result;
    }


}
